<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //1.charAt(index) 根据位置返回字符
        var str = 'andy';
        console.log(str.charAt(3));
        for (var i = 0; i < str.length; i++) {   //遍历字符串
            console.log(str.charAt(i));
        }

        //2.charCodeAt(index)  //返回当前相应索引号的字符ASCII码值 目的是：判断用户按下那个键
        console.log(str.charCodeAt(0)); //a的ascii码值是97

        //3.str[index] h5新增
        console.log(str[0]);
    </script>
</head>

<body>

</body>

</html>